package com.webinsky.persist.dao.user;

import java.util.Map;

import com.webinsky.common.proj.DelFlag;
import com.webinsky.domain.user.AccountFilter;

public class UserSQLProvider {
	private static final String Basic_SQL = " select id, login_name, login_password, name, role, del, create_at, update_at, site_id from user";
	
	public String selectByFilter(Map<String, Object> param){
		AccountFilter filter = (AccountFilter)param.get("filter");
		String sql = Basic_SQL;
		sql = sql + " where del = " + DelFlag.UNDel.getFlag();
		if ( filter != null ){
			if ( filter.getId() > 0 ){
				sql = sql + " and id = " + filter.getId() + "";
			}
			if ( filter.getLoginName() != null ){
				sql = sql + " and login_name = '" + filter.getName() + "'";
			}
			if ( filter.getName() != null ){
				sql = sql + " and name like '%" + filter.getName() + "%'";
			}
		}
		return sql;
	}
}
